function [P, Q, V, theta, nbus, busname, branch_conns, nTimeStamp, branch_powers, load_curves] = caseTaiwanMatpower(time1, time2, time_span_minutes, edge_status, load_curves)
    % caseTaiwanMatpower
    % time1和time2为字符向量或者字符串，格式为HH:mm:ss，如'01:02:00'。
    %   time1为起始时间，time2为结束时间。
    %time_span_minutes 仿真间隔分钟数
    % edge_status，具有fbus、tbus、status三个字段的表，每条边的是否在运行，覆盖算例中仿真状态，用来变更拓扑。
    % load_curves, 仿真负荷曲线。如果使用函数返回的结构体，则能够复现。
    % @example:[P,Q,V,theta,nbus,busname,branch_conns,nTimeStamp, branch_powers, load_curves]=caseTaiwanMatpower('01:02:00','02:02:02'，2);
    % @note:算例数据写在“台湾算例mattpower格式.xlsx”文件里。

    %% default argument
    time1 = duration(time1, 'InputFormat', 'hh:mm:ss');
    time2 = duration(time2, 'InputFormat', 'hh:mm:ss');

    if ~exist ('time_span_minutes', 'var')
        time_span_minutes = int32(2);
    end

    if time_span_minutes <= 0
        error('曲线抽样时间跨度必须为正数')
    end

    %% 导入算例数据
    disp 正在仿真台湾算例; 
    profile = readtable('台湾算例mattpower格式.xlsx', 'sheet', 'profile');
    mpc.version = profile{1, 'version'};
    mpc.baseMVA = profile{1, 'baseMVA'};
    bus_table = readtable('台湾算例mattpower格式.xlsx', 'sheet', 'bus');
    gen_table = readtable('台湾算例mattpower格式.xlsx', 'sheet', 'gen');
    branch_table = readtable('台湾算例mattpower格式.xlsx', 'sheet', 'branch');
    mpc.bus = table2array(bus_table);
    mpc.gen = table2array(gen_table);
    mpc.branch = table2array(branch_table);

    define_constants;
    mpopt = mpoption('verbose', 0, 'out.all', 0);

    %% 提取信息
    nbus = size(mpc.bus, 1);
    nbranch = size(mpc.branch, 1);
    busname = mpc.bus(:, BUS_I);
    branch_conns = mpc.branch(:, [F_BUS, T_BUS, BR_R, BR_X, BR_STATUS]);

    %% 抽样生成节点负荷曲线
    if ~exist('time_span_minutes', 'var')
        time_span_minutes = int32(2);
    end

    user_table = readtable('台湾算例mattpower格式.xlsx', 'sheet', '节点用户数量', 'VariableNamingRule', 'preserve');
    file_name = compose('%s/load Profiles/Load_profile_%d.csv', getWorkPath(), (1:100).');
    ratedPQ.P = mpc.bus(:, PD);
    ratedPQ.Q = mpc.bus(:, QD);
    ratedPQ.users = user_table{:, 2};
    ratedPQtable = struct2table(ratedPQ);
    span = abs(minutes(time2 - time1));
    X = time1 + minutes(1:time_span_minutes:span);
    nTimeStamp = length(X);

    if exist('load_curves', 'var') && isstruct(load_curves)
        [PQcurve, ~] = LoadAllocate(load_curves, ratedPQtable, X);
    else
        [PQcurve, load_curves] = LoadAllocate(file_name, ratedPQtable, X);
    end

    load_curve_P = zeros(nbus, nTimeStamp);
    load_curve_Q = zeros(nbus, nTimeStamp);

    for k = 1:nbus
        load_curve_P(k, :) = PQcurve{k}(1, :);
        load_curve_Q(k, :) = PQcurve{k}(2, :);
    end

    %% 覆盖拓扑
    if exist('edge_status', 'var') && ~isempty(edge_status)
        if istable(edge_status)
        [~, ia, ib] = intersect(branch_table(:, {'fbus', 'tbus'}), edge_status(:, {'fbus', 'tbus'}));
        branch_table{ia, 'status'} = edge_status{ib, 'status'};
        mpc.branch = table2array(branch_table);
        else
            error('edge_status必须为表格')
        end
    end

    %% 启动仿真
    P = zeros(nbus, nTimeStamp);
    Q = zeros(nbus, nTimeStamp);
    V = zeros(nbus, nTimeStamp);
    theta = zeros(nbus, nTimeStamp);
    branch_powers = zeros(size(branch_conns, 1), 4 * nTimeStamp);

    n_fail_stamp = 0;

    for t = 1:nTimeStamp
        %负荷跟随曲线变动
        mpc.bus(:, PD) = load_curve_P(:, t);
        mpc.bus(:, QD) = load_curve_Q(:, t);
        %修改变电站出口电压，在1.04到1.055之间随机波动
        %实际上是改发电机电压
        mpc.gen(:, VG) = rand(size(mpc.gen(:, VG))) .* (1.055 - 1.04) + 1.04;
        %启动仿真
        results = runpf(mpc, mpopt);

        if results.success
            P(:, t) = results.bus(:, PD) * (-1);
            Q(:, t) = results.bus(:, QD) * (-1);
            V(:, t) = results.bus(:, VM);
            theta(:, t) = results.bus(:, VA);
            branch_powers(:, 4 * (t - 1) + 1) = results.branch(:, PF); branch_powers(:, 4 * (t - 1) + 2) = results.branch(:, QF);
            branch_powers(:, 4 * (t - 1) + 3) = results.branch(:, PT); branch_powers(:, 4 * (t - 1) + 4) = results.branch(:, QT);
            P(results.gen(:, GEN_BUS), t) = P(results.gen(:, GEN_BUS), t) + results.gen(:, PG);
            Q(results.gen(:, GEN_BUS), t) = Q(results.gen(:, GEN_BUS), t) + results.gen(:, QG);
        else
            warning(['第' num2str(t) '次计算失败，向数据结果写入NaN']);
            P(:, t) = NaN(nbus, 1);
            Q(:, t) = NaN(nbus, 1);
            V(:, t) = NaN(nbus, 1);
            theta(:, t) = results.bus(:, VA);
            branch_powers(:, 4 * (t - 1) + 1:4 * t) = NaN(nbranch, 4);
            n_fail_stamp = n_fail_stamp + 1;
        end

    end

    branch_conns = [branch_conns branch_powers];

    if n_fail_stamp > 0
        disp(['共计' num2str(n_fail_stamp) '次计算失败']);
    end

end
